home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 7.3 KB | 270 lines | [TEXT/MPS ] |
- // UCalcColumns.h
- // Copyright © 1986-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UCALCCOLUMNS__
- #define __UCALCCOLUMNS__
-
- //
- // INTERNAL INCLUDES FOR CALC
- //
-
- #ifndef __UCALC__
- #include "UCalc.h"
- #endif
-
- #ifndef __CALCUTILITIES__
- #include "CalcUtilities.h"
- #endif
-
- class TCalcDocument;
- class TColumn;
- class TColumnsView;
- class TColumnList;
- class CColumnIterator;
-
- //--------------------------------------------------------------------------------------------------
- // TColumnsView: TColumnsView is used to show the column headers, represented by the
- // letters A-BL. Click in this view to select an entire column or group of columns.
- //--------------------------------------------------------------------------------------------------
-
- class TColumnsView : public TTextGridView
- {
- MA_DECLARE_CLASS;
-
- public:
-
- TCalcDocument* fCalcDocument;
-
- virtual ~TColumnsView();
- // Destructor
-
- virtual void DoPostCreate(TDocument* itsDocument);// override
- // Create the view from a resource template
-
- virtual void AdornCol(short aCol, const VRect& /*area*/);// override
- // Draw a column delimiter in the given area
-
- virtual void CoordToString(short coord, CStr255& theString);
-
- virtual void DoMouseCommand(VPoint& theMouse,
- TToolboxEvent* event,
- CPoint /*hysteresis*/);// override
-
- virtual void DoSetCursor(const VPoint& localPoint,
- RgnHandle cursorRegion);// override
-
- virtual void DrawCell(GridCell aCell,
- const VRect& aRect);// override
-
- virtual void ReSelect(RgnHandle cellRegion);
-
- }; // TColumnsView
-
-
- //--------------------------------------------------------------------------------------------------
- // TColumn:
- //--------------------------------------------------------------------------------------------------
-
- class TColumn : public TObject
- {
- MA_DECLARE_CLASS;
-
- public:
-
- short fNumber;
- FormatRecord fFormat;
- FormatRecord fOldFormat; // save original format for Undo
- short fWidth;
-
- TColumn();
- // Constructor
-
- virtual ~TColumn();
- // Destructor
-
- virtual void IColumn(short number);
-
- virtual void ReadFromDisk(TFile* aFile);
-
- virtual void WriteToDisk(TFile* aFile);
-
- virtual void ReadFromScrap(Handle theScrap,
- long& scrapOffset);
-
- virtual void WriteToScrap(Handle theScrap,
- long& scrapOffset);
-
- }; // TColumn
-
-
- //--------------------------------------------------------------------------------------------------
- // TColumnList:
- //--------------------------------------------------------------------------------------------------
-
- class TColumnList : public TSortedList
- {
- MA_DECLARE_CLASS;
-
- public:
- virtual ~TColumnList();
- // Destructor
-
- virtual void IColumnList();
- // Init the list procedurally
-
- virtual CompareResult Compare(TObject* item1,
- TObject* item2);// override
- // Compares columns based on columns number
-
- virtual TColumn* GetColumn(ColumnNumber c);
- // Returns the column whose number is c
- }; // TColumnList
-
-
- //--------------------------------------------------------------------------------------------------
- // TColumnSelector: TColumnSelector is a command object created to handle mouse movement
- // when you click in a TColumnsView.
- //--------------------------------------------------------------------------------------------------
-
- class TColumnSelector : public TCalcSelectCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TCalcSelectCommand* fCellSelector; // command to handle cells view selection
-
- TColumnSelector(); // override
-
- virtual void IColumnSelector(TCalcDocument* itsDocument,
- TGridView* itsView,
- VPoint& theMouse,
- Boolean theShiftKey,
- Boolean theCommandKey);
- /* Create a TCalcSelectCommand to handle selection in the cells view in parallel with
- selection in our view, the column headers */
-
- virtual ~TColumnSelector(); // override
- // Dispose of our cell selector
-
- virtual void ComputeAnchorCell(GridCell& clickedCell);// override
- virtual void ComputeNewSelection(GridCell& clickedCell);// override
- virtual void DoIt(); // override
- // Perform these operations for the cells view as well as for the column headers
-
- virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
- VPoint& /*anchorPoint*/,
- VPoint& /*previousPoint*/,
- VPoint& nextPoint,
- Boolean mouseDidMove);// override
-
- }; // TColumnSelector
-
-
- //--------------------------------------------------------------------------------------------------
- // TColumnFormatter: TColumnFormatter is a command object created to change the style or
- // justification of a column. It is not undoable.
- //--------------------------------------------------------------------------------------------------
-
- class TColumnFormatter : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TCalcDocument* fCalcDocument;
- RgnHandle fSelection; // columns selected for formatting
-
- virtual void IFormatter(TCalcDocument* itsDocument,
- CommandNumber itsCommand);
-
- virtual ~TColumnFormatter(); // override
-
- virtual void DoIt(); // override
- virtual void UndoIt(); // override
- virtual void RedoIt(); // override
-
- protected:
- void SaveFormat(GridCell aCell);
-
- void SetFormat(GridCell aCell);
-
- void RestoreFormat(GridCell aCell);
-
- }; // TColumnFormatter
-
-
- //--------------------------------------------------------------------------------------------------
- // TColumnSizer: TColumnSizer is a command object created to handle mouse movement when
- // you click on the boundary between two columns.
- //--------------------------------------------------------------------------------------------------
-
- class TColumnSizer : public TTracker
- {
- MA_DECLARE_CLASS;
-
- public:
-
- TCalcDocument* fCalcDocument;
- TCellsView* fCellsView;
- short fLeftEdge;
-
- TColumn* fColumn;
- short fNewWidth;
- short fOldWidth; // remember previous width for Undo
-
- virtual ~TColumnSizer();
- // Destructor
-
- virtual void IColumnSizer(TCalcDocument* itsDocument,
- ColumnNumber c,
- VPoint theMouse);
-
- virtual TTracker* TrackMouse(TrackPhase /*aTrackPhase*/,
- VPoint& /*anchorPoint*/,
- VPoint& /*previousPoint*/,
- VPoint& nextPoint,
- Boolean /*mouseDidMove*/);
-
- virtual void TrackFeedback(TrackPhase /*aTrackPhase*/,
- const VPoint& /*anchorPoint*/ ,
- const VPoint& /*previousPoint*/ ,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean /*turnItOn*/);// override
-
- virtual void TrackConstrain(TrackPhase /*aTrackPhase*/,
- const VPoint& /*anchorPoint*/ ,
- const VPoint& /*previousPoint*/ ,
- VPoint& nextPoint,
- Boolean /*mouseDidMove*/);// override
-
- virtual void DoIt(); // override
-
- virtual void UndoIt(); // override
-
- virtual void SetColumnWidth(short newWidth);
-
- }; // TColumnSizer
-
-
- class CCalcColumnIterator : public CObjectIterator
- {
- public:
- CCalcColumnIterator(TCalcDocument* theCalcDocument);
-
- CCalcColumnIterator(TColumnList* theColumnList);
-
- virtual ~CCalcColumnIterator();
-
- virtual TColumn* CurrentColumn();
- // returns the current Column
-
- virtual TColumn* FirstColumn();
- // return the first Column in the iteration
-
- virtual TColumn* NextColumn();
- // advances the iteration and then returns the Column
- };
-
- #endif //UCALCCOLUMNS
-
-